package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.query.StrategyCatalogQueryObject;
import cn.wolfcode.trip.base.query.StrategyCommentQueryObject;
import cn.wolfcode.trip.base.query.StrategyQueryObject;
import cn.wolfcode.trip.base.service.IStrategyCatalogService;
import cn.wolfcode.trip.base.service.IStrategyCommentService;
import cn.wolfcode.trip.base.service.IStrategyService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 大攻略资源控制器
 */
@RestController
@RequestMapping("strategies")
public class StrategyController {
    @Autowired
    private IStrategyService strategyService;
    @Autowired
    private IStrategyCatalogService strategyCatalogService;
    @Autowired
    private IStrategyCommentService strategyCommentService;


    /**
     *获取大攻略中状态为推荐的所有攻略
     * @param qo
     * @return
     */
    @GetMapping
    public PageInfo query(StrategyQueryObject qo){
        PageInfo pageInfo = strategyService.query(qo);
        return pageInfo;
    }

    /**
     * 获取某个大攻略下的所有攻略分类
     * @param qo
     * @return
     */
    @GetMapping("/{strategyId}")
    public PageInfo selectQueryByStrategyId(StrategyCatalogQueryObject qo){
        qo.setState(true);//设置状态为启用状态
        qo.setPageSize(0);//查询全部
        PageInfo pageInfo = strategyCatalogService.query(qo);
        return pageInfo;
    }

    /**
     * 获取某个大攻略的所有评论信息
     * @param qo
     * @return
     */
    @GetMapping("/{strategyId}/comments")
    public PageInfo selectCommentByStrategyId(StrategyCommentQueryObject qo){
        qo.setState(1);//设置评论状态为正常
        PageInfo pageInfo = strategyCommentService.query(qo);
        return pageInfo;
    }
    /**
     * 获取某一大攻略下所有的标签排名前6的
     * @param qo
     * @return
     */
    @GetMapping("/{strategyId}/tags")
    public List selectTagsByStrategyId(StrategyCommentQueryObject qo){
        List list = strategyCommentService.selectTagsByStrategyId(qo);
        return list;
    }

}
